#include "Material.h"

Material::Material()
{
}

void Material::SetBasicLight(Shader *vpBasicLight, Shader *fpBasicLight)
{
	this ->vpBasicLight = vpBasicLight;
	this ->fpBasicLight = fpBasicLight;
}

Material::~Material(void)
{
}

void Material::SetMaterial()
{
	/*vpBasicLight ->DoShader();
	fpBasicLight ->DoShader();*/

	/*cgGLSetStateMatrixParameter(
		cgGetNamedParameter(fpBasicLight ->GetProgram(), "modelViewProj"),
		CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);*/

	CGprogram cgFpPrg = fpBasicLight ->GetProgram();

	cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "ambient"), 0.01f, 0.01f, 0.01f, 1.0f);
	cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "diffuse"), 0.1f, 0.1f, 0.1f, 1.0f);
	cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "specular"), 0.3f, 0.3f, 0.3f, 1.0f);
	cgGLSetParameter1f(cgGetNamedParameter(cgFpPrg, "glossiness"), 8.0f);
	cgGLSetParameter1f(cgGetNamedParameter(cgFpPrg, "specularLevel"), 1.0f);

	/*cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "ambient"), 0.0f, 0.0f, 0.0f, 1.0f);
	cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "diffuse"), 0.0f, 0.0f, 0.0f, 1.0f);
	cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "specular"), 0.0f, 0.0f, 0.0f, 1.0f);
	cgGLSetParameter1f(cgGetNamedParameter(cgFpPrg, "glossiness"), 8.0f);
	cgGLSetParameter1f(cgGetNamedParameter(cgFpPrg, "specularLevel"), 1.0f);*/

	/*
	cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "ambient"), ambient.x, ambient.y, ambient.z, 1.0f);
	cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "diffuse"), diffuse.x, diffuse.y, diffuse.z, 1.0f);
	cgGLSetParameter4f(cgGetNamedParameter(cgFpPrg, "specular"), specular.x, specular.y, specular.z, 1.0f);
	cgGLSetParameter1f(cgGetNamedParameter(cgFpPrg, "glossiness"), 8.0f);
	cgGLSetParameter1f(cgGetNamedParameter(cgFpPrg, "specularLevel"), 1.0f);*/

	if (texture != NULL)
	{
		cgGLSetTextureParameter(cgGetNamedParameter(cgFpPrg, "tex0"), texture ->GetId());
		cgGLEnableTextureParameter(cgGetNamedParameter(cgFpPrg, "tex0"));
		/*glEnable(GL_TEXTURE_2D);
		texture ->BindTexture();*/
	}
	//else
		//glDisable(GL_TEXTURE_2D);
}